package org.example.math;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/07/03 9:53
 */
public class Solution3099 {

    public static void main(String[] args) {
        System.out.println(new Solution3099().sumOfTheDigitsOfHarshadNumber(18));
    }

    public int sumOfTheDigitsOfHarshadNumber(int x) {

        int count = 0;
        int num = x;
        while (num > 0){
            count+= num % 10;
            num = num / 10;
        }
        return  x % count == 0 ? count : -1;
    }
}
